/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.NameManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ListAppCustomersName extends AbstractAction
/*    */ {
/* 28 */   private static Logger logger = Logger.getLogger(ListAppCustomersName.class
/* 29 */     .getName());
/*    */ 
/*    */   public ListAppCustomersName(AbstractHttpServlet servlet)
/*    */   {
/* 32 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 39 */     response.setContentType("text/html;charset=utf-8");
/* 40 */     PrintWriter out = response.getWriter();
/* 41 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 43 */     User user = super.getLoginUser(request);
/* 44 */     String term = Util.getURLParameter(request.getParameter("term"));
/* 45 */     NameManager manager = new NameManager();
/* 46 */     int companyId = super.getLoginUser(request).companyId;
/*    */ 
/* 48 */     int groupId = 0;
/* 49 */     if (user.isGroupAdmin)
/* 50 */       groupId = user.groupId;
/*    */     try
/*    */     {
/* 53 */       List result = manager.searchCustomerName(
/* 54 */         companyId, term, user.isAdmin, user.userId, groupId, true);
/*    */ 
/* 56 */       jsonObject.put("error", "0");
/* 57 */       jsonObject.put("customers", result);
/*    */     } catch (DBException e) {
/* 59 */       logger.warn(e);
/* 60 */       jsonObject.put("error", "1");
/* 61 */       jsonObject.put("msg", "客户一览加载失败");
/*    */     } catch (SQLException e) {
/* 63 */       logger.warn(e);
/* 64 */       jsonObject.put("error", "1");
/* 65 */       jsonObject.put("msg", "客户一览加载失败");
/*    */     }
/* 67 */     out.println(jsonObject);
/* 68 */     out.flush();
/* 69 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ListAppCustomersName
 * JD-Core Version:    0.6.1
 */